<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title th:text="${'登陆-'+sysConfig.websiteTitle}">后台管理系统</title>
    <link rel="icon" th:href="${sysConfig.websiteIcon}">
    <meta name="keywords" th:content="${sysConfig.websiteKeywords}">
    <meta name="description" th:content="${sysConfig.websiteDesc}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" th:href="@{/images/favicon.ico}">
    <link rel="stylesheet" th:href="@{/layuimini/lib/layui-v2.6.3/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/layuimini/css/layuimini.css}" media="all">
    <link rel="stylesheet" th:href="@{/layuimini/lib/font-awesome-4.7.0/css/font-awesome.min.css}" media="all">
    <link rel="stylesheet" th:href="@{/layuimini/css/public.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/index.css}" media="all">
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style id="layuimini-bg-color">
    </style>
</head>
<body class="layui-layout-body layuimini-all">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header header">
        <div class="layui-logo layuimini-logo"></div>
        <div class="layuimini-header-content">
            <a>
                <div class="layuimini-tool"><i title="展开" class="fa fa-outdent" data-side-fold="1"></i></div>
            </a>

            <!--电脑端头部菜单-->
            <ul class="layui-nav layui-layout-left layuimini-header-menu layuimini-menu-header-pc layuimini-pc-show">
            </ul>

            <!--手机端头部菜单-->
            <ul class="layui-nav layui-layout-left layuimini-header-menu layuimini-mobile-show">
                <li class="layui-nav-item">
                    <a href="javascript:;"><i class="fa fa-list-ul"></i> 选择模块</a>
                    <dl class="layui-nav-child layuimini-menu-header-mobile">
                    </dl>
                </li>
            </ul>

            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item mobile layui-hide-xs now-time" lay-unselect>
                    <span id="nowTime" style="padding: 0 20px"></span>
                </li>
                <li class="layui-nav-item mobile layui-hide-xs lock-screen" lay-unselect>
                    <a href="javascript:;" data-lock="锁屏" title="锁屏" id="lock-screen"><i class="fa fa-lock"></i></a>
                </li>
                <li class="layui-nav-item" lay-unselect>
                    <a href="javascript:;" data-refresh="刷新"><i class="fa fa-refresh"></i></a>
                </li>
                <li class="layui-nav-item" lay-unselect>
                    <a href="javascript:;" data-clear="清理" class="layuimini-clear"><i class="fa fa-trash-o"></i></a>
                </li>
                <li class="layui-nav-item mobile layui-hide-xs" lay-unselect>
                    <a href="javascript:;" data-check-screen="full"><i class="fa fa-arrows-alt"></i></a>
                </li>
                <li class="layui-nav-item layuimini-setting">
                    <a href="javascript:;" th:text="${sysUser.nickName}"></a>
                    <dl class="layui-nav-child" style="top: 60px;padding: 0px;">
                        <dd>
                            <a href="javascript:;" layuimini-content-href="system/sysUser/userSetting" data-title="基本资料" data-icon="fa fa-gears">基本资料<span class="layui-badge-dot"></span></a>
                        </dd>
                        <dd>
                            <a href="javascript:;" layuimini-content-href="system/sysUser/userPassword" data-title="修改密码" data-icon="fa fa-gears">修改密码</a>
                        </dd>
                        <dd>
                            <hr>
                        </dd>
                        <dd>
                            <a href="javascript:;" class="login-out">退出登录</a>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item layuimini-select-bgcolor" lay-unselect>
                    <a href="javascript:;" data-bgcolor="配色方案"><i class="fa fa-ellipsis-v"></i></a>
                </li>
            </ul>
        </div>
    </div>

    <!--无限极左侧菜单-->
    <div class="layui-side layui-bg-black layuimini-menu-left">
    </div>

    <!--初始化加载层-->
    <div class="layuimini-loader">
        <div class="layuimini-loader-inner"></div>
    </div>

    <!--手机端遮罩层-->
    <div class="layuimini-make"></div>

    <!-- 移动导航 -->
    <div class="layuimini-site-mobile"><i class="layui-icon"></i></div>

    <div class="layui-body">
        <div class="layuimini-tab layui-tab-rollTool layui-tab" lay-filter="layuiminiTab" lay-allowclose="true">
            <ul class="layui-tab-title">
                <li class="layui-this" id="layuiminiHomeTabId" lay-id=""></li>
            </ul>
            <div class="layui-tab-control">
                <li class="layuimini-tab-roll-left layui-icon layui-icon-left"></li>
                <li class="layuimini-tab-roll-right layui-icon layui-icon-right"></li>
                <li class="layui-tab-tool layui-icon layui-icon-down">
                    <ul class="layui-nav close-box">
                        <li class="layui-nav-item">
                            <a href="javascript:;"><span class="layui-nav-more"></span></a>
                            <dl class="layui-nav-child">
                                <dd><a href="javascript:;" layuimini-tab-close="current">关闭当前</a></dd>
                                <dd><a href="javascript:;" layuimini-tab-close="other">关闭其他</a></dd>
                                <dd><a href="javascript:;" layuimini-tab-close="all">关闭全部</a></dd>
                            </dl>
                        </li>
                    </ul>
                </li>
            </div>
            <div class="layui-tab-content">
                <div id="layuiminiHomeTabIframe" class="layui-tab-item layui-show"></div>
            </div>
        </div>
    </div>
</div>
<!-- 锁屏窗口 -->
<div id="lock-container" style="display: none">
    <form class="layui-form" action="" lay-filter="formLock">
        <div id="lock-box" class="admin-header-lock">
            <div class="admin-header-lock-img">
                <img th:src="${sysUser?.userAvatar}"/>
            </div>
            <div class="input_btn">
                <input type="password" name="password" class="layui-input admin-header-lock-input" placeholder="请输入登录密码" />
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="formLock">解锁</button>
            </div>
        </div>
    </form>
</div>
<!-- 图像预览窗口 -->
<div id="avatar-preview" style="display: none">
    <div style="width: 100%; height: 100%; overflow: hidden">
        <img src="" style="width: 50%; cursor: move;position: absolute;">
    </div>
</div>
<script th:src="@{/layuimini/lib/layui-v2.6.3/layui.js}" charset="utf-8"></script>
<script th:src="@{/layuimini/js/lay-config.js}" charset="utf-8"></script>
<script type="text/javascript" th:inline="javascript">
    layui.use(['jquery','form','util','layer','miniAdmin','miniTongji','miniTab'], function () {
        let $ = layui.jquery,
            layer = layui.layer,
            form = layui.form,
            util = layui.util,
            miniAdmin = layui.miniAdmin,
            miniTab = layui.miniTab,
            miniTongji = layui.miniTongji;

        let ctxPath = /*[[@{/}]]*/'';

        let bgColorDefault = 0;
        let multiModule = true;
        //加载系统参数
        $.ajax({
            type:'GET',
            url:ctxPath+'system/sysParam/paramList',
            dataType:'json',
            success:function (res){
                if(res.code === 0){
                    $.each(res.data,function (k,v){
                        if(v.paramKey === 'system|theme'){
                            bgColorDefault = v.paramValue;
                        }
                        if(v.paramKey === 'system|theme|nav|module'){
                            multiModule = v.paramValue === 'true' ? true : false;
                        }
                    })

                    //配置主页参数
                    let options = {
                        iniUrl: ctxPath+"initMenu",        // 初始化接口
                        urlHashLocation: true,             // 是否打开hash定位
                        bgColorDefault: bgColorDefault,    // 主题默认配置
                        multiModule: multiModule,          // 是否开启多模块
                        menuChildOpen: false,       // 是否默认展开菜单
                        loadingTime: 0,             // 初始化加载时间
                        pageAnim: true,             // iframe窗口动画
                        maxTabNum: 20,              // 最大的tab打开数量
                    };
                    //初始化主页
                    miniAdmin.render(options);
                }
            }
        });

        //初始化最上面的时间
        getLangDate();
        //渲染时间
        function getLangDate(){
            let dateObj = new Date();               //表示当前系统时间的Date对象
            let day = dateObj.getDay();             //当前系统时间中的星期值
            let weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
            let week = weeks[day];                  //根据星期值，从数组中获取对应的星期字符串
            let hour = dateObj.getHours();          //当前系统时间的小时值
            let timeValue = '';
            if(8 <= hour && hour < 12){
                timeValue = '上午好，加油年轻人';
            }else if(12 <= hour && hour < 14){
                timeValue = '中午好，休息一下吧';
            }else if(14 <= hour && hour < 18){
                timeValue = '下午好，伸个懒腰吧';
            }else if(18 <= hour && hour < 23){
                timeValue = '下班了，多陪陪家人';
            }else {
                timeValue = '夜深了，早点休息吧';
            }
            let newDate = util.toDateString(new Date(), 'yyyy年MM月dd日 HH:mm:ss');
            $('#nowTime').html(newDate + "&nbsp&nbsp" + week+ "&nbsp&nbsp&nbsp&nbsp" + timeValue);
            setTimeout(getLangDate,1000);
        };

        //点击锁屏
        $('#lock-screen').click(function () {
            lockPage();
            window.localStorage.setItem("lockcms", true);
        });
        //刷新时判断是否锁屏
        if(window.localStorage.getItem("lockcms") == "true"){
            setTimeout(function () {
                lockPage();
            }, 1000)
        }else{
            //判断是否初始密码
            let isDefaultPassword = [[${defaultPassword}]];
            if(isDefaultPassword){
                let index = layer.confirm('您的密码为系统初始密码，请尽快修改密码', {
                    btn: ['修改', '忽略'],
                    icon: 3
                }, function(){
                    miniTab.openNewTabByIframe({title: '修改密码', href: ctxPath + 'system/sysUser/userPassword'});
                    layer.close(index);
                }, function(){
                    layer.close(index);
                });
            }
        }
        // 弹出锁屏页面
        function lockPage(){
            layer.open({
                title : false,
                type : 1,
                content : $('#lock-container'),
                closeBtn : 0,
                shade : [1, '#49A9EE'],
            })
            //关闭页面检查
            // webCheck(false);
        };
        //点击解锁
        form.on('submit(formLock)', function(res){
            let data = res.field;
            if(!data.password){
                layer.msg('请输入登录密码');
                return false;
            }

            $.ajax({
                type:'POST',
                url:ctxPath+'unlock',
                data: {password:data.password},
                dataType:'json',
                success:function (res){
                    if(res.code === 200){
                        window.localStorage.setItem("lockcms", false);
                        form.val("formLock", {password: ''});
                        layer.closeAll("page");
                        webCheck(true);
                    }else {
                        layer.msg(res.msg);
                    }
                }
            });
            return false;
        });

        // 禁用网页检查
        function webCheck(flag) {
            // 禁用f12
            document.onkeydown = function() {
                if(event.keyCode == 123) {
                    return flag;
                }
            };
            // 禁用右键
            $(document).ready(function(){
                $(document).bind("contextmenu",function(e){
                    return flag;
                });
            });
        };
        /** 图片预览 */
        function previewImg(url) {
            if(!!url){
                $('#avatar-preview').find("img").attr('src', url);
                $('#avatar-preview').find('img').css({
                    inset: '0 0 0 0',
                    margin: 'auto',
                    width: '50%'
                });
                layer.open({
                    title: false,
                    type: 1,
                    area: ['1200px', '800px'],
                    content: $('#avatar-preview'),
                    shadeClose: true
                });
            }
        }

        // 退出登录
        $('.login-out').on("click", function () {
            layer.confirm('你确认退出登录吗？', {
                btn: ['确定'],
                title: '提示',
                icon: 3
            }, function(){
                window.location.href = ctxPath + 'logout';
            });
        });

        // 百度统计代码，只统计指定域名
        miniTongji.render({
            specific: true,
            domains: [
                '99php.cn',
                'layuimini.99php.cn',
                'layuimini-onepage.99php.cn',
            ],
        });
    });
</script>
</body>
</html>
